package cz.muni.fi.pa165.machineryrental.dto;

import java.io.Serializable;
import java.util.Date;

/**
 * Data Transfer Object for Machine
 *
 * @author Martin Klvana, 395893
 */
public class MachineDTO implements Serializable {

    /**
     * Unique id.
     */
    private long id = 0;
    /**
     * Machine code.
     */
    private String code;
    /**
     * Name of machine brand.
     */
    private String brand;
    /**
     * Name of machine model.
     */
    private String model;
    /**
     * Date of machine production start.
     */
    private Date yearOfProduction;

    /**
     * Returns identifier of machine
     *
     * @return Identifier of machine
     */
    public long getId() {
        return id;
    }

    /**
     * Sets given id.
     *
     * @param id Id of machine.
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * Returns code of machine.
     *
     * @return Code of machine.
     */
    public String getCode() {
        return code;
    }

    /**
     * Sets machine code.
     *
     * @param code String of machine.
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Returns brand of machine.
     *
     * @return Brand of machine.
     */
    public String getBrand() {
        return brand;
    }

    /**
     * Sets machine brand.
     *
     * @param brand String of machine.
     */
    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * Returns model of machine.
     *
     * @return model of machine.
     */
    public String getModel() {
        return model;
    }

    /**
     * Sets machine model.
     *
     * @param model String of machine model.
     */
    public void setModel(String model) {
        this.model = model;
    }

    /**
     * Returns date of machine production start.
     *
     * @return Date of machine production start.
     */
    public Date getYearOfProduction() {
        return yearOfProduction;
    }

    /**
     * Sets date, when was machine production started.
     *
     * @param yearOfProduction Date when machine production started.
     */
    public void setYearOfProduction(Date yearOfProduction) {
        this.yearOfProduction = yearOfProduction;
    }

    @Override
    public String toString() {
        return "MachineDTO{" + "id=" + id + ", code=" + code + ", brand=" + brand + ", model=" + model + ", yearOfProduction=" + yearOfProduction + '}';
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (id ^ (id >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof MachineDTO)) {
            return false;
        }
        MachineDTO other = (MachineDTO) obj;
        return id == other.id;
    }
}
